//
//  ViewController.m
//  UIButton UIImageView
//
//  Created by Justsoso on 16/2/21.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *numLabel;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UITextView *sayTextView;
@property (weak, nonatomic) IBOutlet UIButton *leftbtn;
@property (weak, nonatomic) IBOutlet UIButton *rightbtn;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)picChang
{
    switch ([self.numLabel.text intValue])
    {
        case 0:
            [self.imageView setImage:[UIImage imageNamed:@"biaoqingdi"]];
            self.sayTextView.text = @"在他面前，其他神马表情都弱爆了！";
            break;
        case 1:
            [self.imageView setImage:[UIImage imageNamed:@"wangba"]];
            self.sayTextView.text = @"哥们为什么选八号呢";
            break;
        case 2:
            [self.imageView setImage:[UIImage imageNamed:@"bingli"]];
            self.sayTextView.text = @"这也忒狠了";
            break;
        case 3:
            [self.imageView setImage:[UIImage imageNamed:@"chiniupa"]];
            self.sayTextView.text = @"这小姑娘吃个牛排比傻牛还费劲";
            break;
        case 4:
            [self.imageView setImage:[UIImage imageNamed:@"danteng"]];
            self.sayTextView.text = @"亲，你能改下你的网名么？哈哈";
            break;
        default:
            break;
    }
}
- (IBAction)leftBtn:(UIButton *)sender
{
    if ([self.numLabel.text intValue] > 0)
    {
        [self.leftbtn setImage:[UIImage imageNamed:@"left_highlighted"] forState:UIControlStateNormal];
        self.numLabel.text = [NSString stringWithFormat:@"%i",[self.numLabel.text intValue]-1];
        if ([self.numLabel.text intValue] < 4)
        {
            [self.rightbtn setImage:[UIImage imageNamed:@"right_highlighted"] forState:UIControlStateNormal];
        }
        [self picChang];
    }
    if([self.numLabel.text intValue] == 0)
    {
        [self.leftbtn setImage:[UIImage imageNamed:@"left_normal"] forState:UIControlStateNormal];
    }
}
- (IBAction)rightBtn:(UIButton *)sender
{
    if ([self.numLabel.text intValue] < 4)
    {
        [self.rightbtn setImage:[UIImage imageNamed:@"right_highlighted"] forState:UIControlStateNormal];
        self.numLabel.text = [NSString stringWithFormat:@"%i",[self.numLabel.text intValue]+1];
        if ([self.numLabel.text intValue] > 0) {
            [self.leftbtn setImage:[UIImage imageNamed:@"left_highlighted"] forState:UIControlStateNormal];
        }
        [self picChang];
    }
    if ([self.numLabel.text intValue] == 4)
    {
        [self.rightbtn setImage:[UIImage imageNamed:@"right_normal"] forState:UIControlStateNormal];
    }
}

@end
